{% extends 'base.html' %}

{% block title %}重置用户密码{% endblock %}

{% block content %}
<div class="container mt-4">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <h4 class="mb-0">重置用户密码</h4>
                </div>
                <div class="card-body">
                    <div class="alert alert-warning">
                        <i class="fas fa-exclamation-triangle"></i>
                        <strong>注意：</strong>此操作将为用户生成一个临时密码，用户需要使用临时密码登录后强制修改密码。
                    </div>
                    
                    <div class="mb-3">
                        <label class="form-label">目标用户：</label>
                        <div class="form-control-plaintext">
                            <strong>{{ target_user.username }}</strong>
                            {% if target_user.email %}
                                ({{ target_user.email }})
                            {% endif %}
                        </div>
                    </div>
                    
                    <div class="mb-3">
                        <label class="form-label">用户信息：</label>
                        <ul class="list-unstyled">
                            <li><strong>姓名：</strong>{{ target_user.first_name }} {{ target_user.last_name }}</li>
                            <li><strong>注册时间：</strong>{{ target_user.date_joined|date:"Y-m-d H:i" }}</li>
                            <li><strong>最后登录：</strong>{{ target_user.last_login|date:"Y-m-d H:i"|default:"从未登录" }}</li>
                            <li><strong>账户状态：</strong>
                                {% if target_user.is_active %}
                                    <span class="badge bg-success">激活</span>
                                {% else %}
                                    <span class="badge bg-danger">未激活</span>
                                {% endif %}
                            </li>
                        </ul>
                    </div>
                    
                    <form method="post">
                        {% csrf_token %}
                        <div class="d-grid gap-2 d-md-flex justify-content-md-end">
                            <a href="{% url 'admin:auth_user_changelist' %}" class="btn btn-secondary me-md-2">取消</a>
                            <button type="submit" class="btn btn-danger">
                                <i class="fas fa-key"></i> 重置密码
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}